<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表页</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>


    <link rel="stylesheet" href="../css/list.css" type="text/css">
</head>
<body>
  
<ul>
</ul>
<script src="../js/list.js"></script>
<script>
let oUl=document.querySelector("ul")

//给uid添加商品数据

//   for(let i=1;i<21;i++){

// $.get('http://jx.xuzhixiang.top/ap/api/goods/goods-add.php/user?',

// {                pimg:"dog"+i+".jpg",
//                   pname:"商品"+i,
//                   pprice:i*10,
//                   pdesc:"狗狗的最爱",
//                   uId:68772,
// },

// (res) => {     
//   console.log(res);
// })}

// 查uid用户下商品,并把商品放置在列表页
let str1=""
$.get("http://jx.xuzhixiang.top/ap/api/productlist.php?uid=68772",
  (res) => {

   console.log(res)

  let proData=res.data
  console.log(proData);
 proData.forEach(function(item){
 str1+=`<li class="proList">
       <a href="../html/detail.html?id=${item.pid}">
       <img src="${item.pimg}"/>
       <p>${item.pname}</p>
       <p>${item.pprice}</p>
       <p>${item.pdesc}</p>
       </a>
    </li>`

     })

     oUl.innerHTML=str1
   }
   )

  let proList=document.querySelectorAll(".proList")
  console.log(proList)
  proList.forEach((item)=>{

  console.log(item)
})






</script>
</body>
</html>